<?php
	
	include '../lib/config.inc.php';
	$id = $_GET['id'];
	
	$sql = "SELECT alunos.id, membros.membro FROM classes_ebd, alunos, membros WHERE classes_ebd.id = alunos.classe_id AND alunos.membro_id = membros.id AND classes_ebd.id = $id ORDER BY classes_ebd.id ASC";

	$result = mysql_query($sql);
	$classe = mysql_fetch_array(mysql_query("SELECT classe FROM classes_ebd WHERE classes_ebd.id = $id"));
	require("../fpdf/fpdf.php");
	
	$pdf= new FPDF("P","pt","A4");
	
	$pdf->AddPage();
	$pdf->SetFont('Times','B',14);
	$pdf->Cell(0,20,utf8_decode("Lista de Chamada - {$classe['classe']}"),0,1,'C');
	$pdf->Cell(535,5,"","B",1,'C');
	$pdf->Ln(20);
	
	$n = 0;
	$pdf->SetFont('Times','b',10);
	$pdf->Cell(50,20,utf8_decode('Matrícula'),1,0,"L");
	$pdf->Cell(155,20,utf8_decode('Nome'),1,0,"L");
	$pdf->Cell(30,20,"",1,0,"L");
	$pdf->Cell(30,20,"",1,0,"L");
	$pdf->Cell(30,20,"",1,0,"L");
	$pdf->Cell(30,20,"",1,0,"L");
	$pdf->Cell(30,20,"",1,0,"L");
	$pdf->Cell(30,20,"",1,0,"L");
	$pdf->Cell(30,20,"",1,0,"L");
	$pdf->Cell(30,20,"",1,0,"L");
	$pdf->Cell(30,20,"",1,0,"L");
	$pdf->Cell(30,20,"",1,0,"L");
	$pdf->Cell(30,20,"",1,0,"L");
	$pdf->Ln();
	$pdf->SetFont('Times','',10);
	while ($row = mysql_fetch_array($result)){
		$pdf->Cell(50,20,utf8_decode($row['id']),1,0,"L");		
		$pdf->Cell(155,20,utf8_decode($row['membro']),1,0,"L");
		$pdf->Cell(30,20,"",1,0,"L");
		$pdf->Cell(30,20,"",1,0,"L");
		$pdf->Cell(30,20,"",1,0,"L");
		$pdf->Cell(30,20,"",1,0,"L");
		$pdf->Cell(30,20,"",1,0,"L");
		$pdf->Cell(30,20,"",1,0,"L");
		$pdf->Cell(30,20,"",1,0,"L");
		$pdf->Cell(30,20,"",1,0,"L");
		$pdf->Cell(30,20,"",1,0,"L");
		$pdf->Cell(30,20,"",1,0,"L");
		$pdf->Cell(30,20,"",1,0,"L");
		$pdf->Ln();
		//$pdf->Cell(140,20,utf8_decode('Membro'),1,0,"L");
		$n++;
	}
	$pdf->Ln(10);
	//$n = mysql_num_rows($sql);
	//$pdf->Cell(150, 20, utf8_decode("Total de Registros: ".$n));
	$pdf->Ln(40);
	
	$pdf->Output("lista-de-chamada.pdf","I");
	
?>